package com.diary;

import com.diary.DBUtils;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class test {
    public static void main(String[] args) {
        Connection connection = null;
        PreparedStatement preparedStatement = null;
        ResultSet resultSet = null;

        try {
            connection = DBUtils.getConnection();
            String sql ="select * from users where user = ? and password = ?";

            preparedStatement = connection.prepareStatement(sql);

            preparedStatement.setString(1,"root");
            preparedStatement.setString(2,"12123");

            resultSet = preparedStatement.executeQuery();

            System.out.println(resultSet);


        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
        finally {
            DBUtils.close(resultSet,preparedStatement, connection);
        }
    }
}
